package com.example.demo.controller;

import com.example.demo.entity.Department;
import com.example.demo.service.DepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author moguai
 * @version 1.0
 * @date 2022/3/20 14:05
 */
@RestController
@RequestMapping("/api")
@Api(tags = "部门操作")
public class DepartmentController {
    @Autowired
    private DepartmentService departmentService;
    @ApiOperation("查找")
    @RequestMapping(value ="/department", method = RequestMethod.GET)
    public Department SelectRole(Integer id){
        return departmentService.SelectDepartment(id);
    }
    @ApiOperation("插入")
    @RequestMapping(value ="/department", method = RequestMethod.POST)
    public void InsertRole(Department department){
        departmentService.InsertDepartment(department.getDepartment_id(),department.getDepartment_name());
    }
    @ApiOperation("更新")
    @RequestMapping(value ="/department", method = RequestMethod.PUT)
    public void UpdateRole(Department department){
        departmentService.UpdateDepartment(department.getDepartment_id(),department.getDepartment_name());
    }
    @ApiOperation("删除")
    @RequestMapping(value ="/department", method = RequestMethod.DELETE)
    public void DeleteRole(Integer id){
        departmentService.DeleteDepartment(id);
    }
}
